package cn.com.codes.common.util;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.ServletContext;

import org.apache.log4j.Logger;
import org.springframework.web.context.ContextLoader;

public class FileUtils {
	
	private static final Logger logger = Logger.getLogger(FileUtils.class);
	
	public static String getWebRootFilePath() {
		ServletContext  servletContext= ContextLoader.getCurrentWebApplicationContext().getServletContext();
		String webRootFilePath = servletContext.getRealPath(File.separator);
		logger.info("webRootFilePath = "+webRootFilePath);
//		logFormatFilePath = logFormatFilePath + "itest"+File.separator+"logs"+File.separator;
//		// 日志文件按照每天分文件夹存放
//		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
//		logFormatFilePath = logFormatFilePath + sdf.format(new Date()) +File.separator;
		return webRootFilePath;
	}
	

}
